package com.net.wanjian.networkhospitalmanager.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.net.wanjian.networkhospitalmanager.R;

/**
 * Description:
 * Created by lidongcai on 17/5/15.
 * Email:  lidongcaiocc@163.com
 */

public class NoDataEmptyView extends RelativeLayout{
    private OnReLoadClickListener onReLoadClickListener;
    private TextView titleTextView1,titleTextView2;
    private Button reloadButton;

    public NoDataEmptyView(Context context) {
        super(context);
    }



    public NoDataEmptyView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context);
    }

    private void init(Context context) {
        //加载视图的布局
        LayoutInflater.from(context).inflate(R.layout.no_data_empty_layout,this,true);
    }

    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();

        //获取子控件
        titleTextView1 = (TextView) findViewById(R.id.laboratory_list_tv1);
        titleTextView2 = (TextView) findViewById(R.id.laboratory_list_tv2);
        reloadButton = (Button) findViewById(R.id.laboratory_list_reload_btn);
        reloadButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                onReLoadClickListener.onReloadClick(v);
            }
        });
    }

//    public void setShowMode(String stateConst){
//        switch (stateConst){
//            case NoDataEmptyViewStateConst.NO_DATA:
//                noData();
//                break;
//            case NoDataEmptyViewStateConst.NO_LAB:
//                noLab();
//                break;
//            case NoDataEmptyViewStateConst.NO_NETWORK:
//                noNetWork();
//                break;
//        }
//    }

    public void setNoNetWork(){
        titleTextView1.setText("没有网络连接～");
        titleTextView2.setVisibility(GONE);
        reloadButton.setVisibility(VISIBLE);
        reloadButton.setText("重新加载");
    }

    public void setNoData(int str){
        titleTextView1.setText(str);
        titleTextView2.setVisibility(GONE);
        reloadButton.setVisibility(VISIBLE);
        reloadButton.setText("刷 新");
    }

    public void setNoLab(int str, int str2){
        titleTextView1.setText(str);
        titleTextView2.setText(str2);
        titleTextView2.setVisibility(VISIBLE);
        reloadButton.setVisibility(VISIBLE);
        reloadButton.setText("刷 新");
    }


    public void setOnReLoadClickListener(OnReLoadClickListener onReLoadClickListener) {
        this.onReLoadClickListener = onReLoadClickListener;
    }

    public interface OnReLoadClickListener{
        void onReloadClick(View v);
    }
}
